home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1987 June
/
Ahoy_Magazine_87-06_1987_Double_L.d64
/
Max Square
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
615b
|
21 lines
0 rem << cd42-10 >>
1 rem ==================================
2 rem commodares problem #38-4 :
3 print"[147]maximum square "
4 rem solution by
5 rem jim speers
6 rem ==================================
100 fora=1to7:forb=a+1to8:forc=b+1to9
110 ia(a)=1:ia(b)=1:ia(c)=1
120 n=1:fori=1to9:ifia(i)=1then140
130 ib(n)=i:n=n+1
140 nexti
150 ford=1to4:fore=d+1to5:forf=e+1to6
160 n=1:k=1:fori=1to6:if(d=iore=iorf=i)thenx(n)=ib(i):n=n+1:goto200
170 y(k)=ib(i):k=k+1
200 nexti:r=a*b*c:s=x(1)*x(2)*x(3):t=y(1)*y(2)*y(3):q=r+s+t
210 ifq>mthenm=q:printa;b;c;"="r:fori=1to3:printx(i);:next:print"=";s:fori=1to3:printy(i);:next:print"=";t:print"total=";m:print""
220 nextf,e,d
230 fori=1to9:ia(i)=0:nexti
240 nextc,b,a